package com.example.myapplication.tack_15.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.R;
import com.example.myapplication.tack_15.data.CommentData;
import com.example.myapplication.tack_15.data.LawyerXQData;
import com.example.myapplication.utils.OkHttpTool;

import java.util.List;

public class LawterXQAdapter extends RecyclerView.Adapter<LawterXQAdapter.My> {
    private LawyerXQData lawyerXQ;
    private Context context;
    private View view;

    public LawterXQAdapter( LawyerXQData lawyerXQ, Context context) {
        this.lawyerXQ = lawyerXQ;
        this.context = context;
    }

    @NonNull
    @Override
    public My onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        view = LayoutInflater.from(context).inflate(R.layout.tack_15_lawyer_xq,null);
        return new My(view);
    }

    @Override
    public void onBindViewHolder(@NonNull My holder, int position) {
        Glide.with(context).load(OkHttpTool.URL + lawyerXQ.getData().getAvatarUrl()).into(holder.avatarUrl);
        holder.name.setText(lawyerXQ.getData().getName());
        holder.serviceTimes.setText("工作时间:"+lawyerXQ.getData().getServiceTimes());
        holder.legalExpertiseName.setText("法律专长:"+lawyerXQ.getData().getLegalExpertiseName());
        holder.baseInfo.setText(lawyerXQ.getData().getBaseInfo());

    }

    @Override
    public int getItemCount() {
        return lawyerXQ != null?1:0;
    }

    public class My extends RecyclerView.ViewHolder{
        private ImageView avatarUrl;
        private TextView name;
        private TextView serviceTimes;
        private TextView legalExpertiseName;
        private TextView baseInfo;
        public My(@NonNull View itemView) {
            super(itemView);
            avatarUrl = view.findViewById(R.id.avatarUrl);
            name = view.findViewById(R.id.name);
            serviceTimes = view.findViewById(R.id.serviceTimes);
            legalExpertiseName = view.findViewById(R.id.legalExpertiseName);
            baseInfo = view.findViewById(R.id.baseInfo);

        }
    }
}
